import Vue from "vue";
Vue.directive("DragWindow" , {
    inserted(el,bind){
        console.log(el)
        let elDialog = el.getElementsByClassName("el-dialog")[0];
        let elDialogHeader = el.getElementsByClassName("el-dialog__header")[0];
        elDialogHeader.style.cursor = "move";
        // 获取当前弹窗的所有样式
        let style = elDialog.currentStyle || window.getComputedStyle(elDialog, null);
        // 弹窗的头部按下的时候进行拖拽
        elDialogHeader.onmousedown = (e)=>{
            let disX = e.clientX - elDialogHeader.offsetLeft;
            let disY = e.clientY - elDialogHeader.offsetTop;
            let styL;
            let styT;
            styL =+ style.left.replace(/\px/g,'');
            styT =+ style.top.replace(/\px/g,'');
            document.onmousemove = function(e){
                let l = e.clientX - disX;
                let t = e.clientY -disY;
                elDialog.style.left = `${l +styL}px`;
                elDialog.style.top = `${t +styT}px`;
            }
            document.onmouseup = function(){
                document.onmouseup = null;
                document.onmousemove = null;
            }
        }
    }
})